﻿using System.Collections.Generic;
using NUnit.Framework;

namespace Dgg.LearnYourTools.NUnit.C_Assertions.c_Collections
{
	[TestFixture]
	public class _023_AssertOnItems
	{
		[Test]
		public void Collection_Unique()
		{
			Assert.That(new[] { 1, 2, 3, 4 }, Is.Unique);
			Assert.That(new[] { 1, 2, 3, 4, 1 }, Is.Not.Unique);
		}

		[Test]
		public void Collection_All()
		{
			Assert.That(new[] { 2, 4, 6 }, Is.All.Matches<int>(i => i % 2 == 0));
			Assert.That(new[] { 2, 4, 6 }, Has.All.Matches<int>(i => i % 2 == 0));
		}

		[Test]
		public void Collection_Some()
		{
			Assert.That(new[] { 2, 4, 6 }, Has.Some.GreaterThanOrEqualTo(4)
				.And.Some.LessThanOrEqualTo(6));
		}

		[Test]
		public void Collection_None()
		{
			Assert.That(new[] { 2, 4, 8 }, Has.None.Matches<int>(i => i % 2 != 0).And.None.GreaterThan(7));
		}

		[Test]
		public void Collection_Member()
		{
			Assert.That(new[] { 2, 4, 6 }, Has.Member(4).And.Not.Member(3));
		}

		[Test]
		public void Array_Length()
		{
			Assert.That(new[]{1, 2, 3}, Has.Length.EqualTo(3));
		}

		[Test]
		public void Collection_Count()
		{
			Assert.That(new List<int> { 1, 2, 3 }, Has.Count.EqualTo(3));
		}
	}
}
